/*
 * event_protocol_event.cpp
 *
 *  Created on: 07.07.2013
 *      Author: SpirTanol
 */

#include "events/event_protocol_event.h"
#include "packets/protocol_packet.h"
#include "global.h"
//=========================================================================================
EventProtocolEvent::EventProtocolEvent(EventData *data) : ProtocolEvent(QDateTime::fromTime_t(data->time()), PET_DEVICE), oData(data)
{

}
EventProtocolEvent::~EventProtocolEvent()
{
	delete oData;
}
//=========================================================================================
int EventProtocolEvent::code() const
{
	return oData->code();
}
//=========================================================================================
QString EventProtocolEvent::toString() const
{
	switch (oData->code())
	{
	case EC_STOP_ENGINE: return QString::fromUtf8("Остановка двигателя");
	case EC_START_ENGINE:
		if (oData->version() >= 50)
			return QString::fromUtf8("Пуск двигателя (максимальная амплитуда тока при пуске ") +
					QString::number(static_cast<EventDataV50*>(oData)->maxAmplitude(), 'f', 1) + QString::fromUtf8("А)");
		return QString::fromUtf8("Пуск двигателя");

	}

	return QString();
}
